//
//  UIImageView+Extension.m
//  ChatForHot
//
//  Created by wr on 2018/10/10.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "UIImageView+Extension.h"

@implementation UIImageView (Extension)

- (void)simple_setImageWithURL:(NSString *)imageUrl
{
    
    //UTF8StringEncoding
    NSString* encodedString = [imageUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [self setImageWithURL:[NSURL URLWithString:encodedString] options:YYWebImageOptionProgressiveBlur|YYWebImageOptionProgressive];
}

- (void)simple_setImageWithURL:(NSString *)imageUrl
                       options:(YYWebImageOptions)options
{
    //UTF8StringEncoding
    NSString* encodedString = [imageUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [self setImageWithURL:[NSURL URLWithString:encodedString] options:options];
}

- (void)simple_setImageWithURL:(NSString *)imageUrl
              placeholderImage:(UIImage *)placeholderImage
{
    //UTF8StringEncoding
    NSString* encodedString = [imageUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [self setImageWithURL:[NSURL URLWithString:encodedString]
              placeholder:placeholderImage
                  options:YYWebImageOptionProgressiveBlur|YYWebImageOptionProgressive
               completion:nil];
}

- (void)simple_setImageWithURL:(NSString *)imageUrl
              placeholderImage:(UIImage *)placeholderImage
                       options:(YYWebImageOptions)options
{
    //UTF8StringEncoding
    NSString* encodedString = [imageUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    
    [self setImageWithURL:[NSURL URLWithString:encodedString] placeholder:placeholderImage options:options completion:nil];
}

- (void)simple_setImageWithURL:(NSString *)imageURL
                   placeholder:(UIImage *)placeholder
                       options:(YYWebImageOptions)options
                     transform:(YYWebImageTransformBlock)transform
                    completion:(YYWebImageCompletionBlock)completion
{
    //UTF8StringEncoding
    NSString* encodedString = [imageURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [self setImageWithURL:[NSURL URLWithString:encodedString] placeholder:placeholder options:options progress:nil transform:transform completion:completion];
}

@end
